#pragma once

#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QSemaphore>
#include "utilities/Locks.h"

class FileWritingReq;
class PacketStorage;

class StorageWatcher : public QThread
{
public:
	StorageWatcher(PacketStorage* storage);
	//~StorageWatcher();
	
	void stopThread();
	void addStorageReq(FileWritingReq* req);

protected:
	void run();

private:
	QQueue<FileWritingReq*> mReqQueue;
	QSemaphore mReqCounter;
	QMutex mRunningLock;
	UsrModeLock mReqLock;
	volatile bool mStopped;
	PacketStorage* mStorageManager;
};